<%@ page language="java" contentType="text/html;charset=utf-8"
	pageEncoding="utf-8"%>

<%@ page import="com.sms.project.*" %>
<%@ page import="java.util.List, java.util.ArrayList, java.util.Map" %>

<%--
	project/teacher/aad-task.jsp
 --%>

<%	//清除内存
	response.setHeader("Pragma","No-cache"); 
	response.setHeader("Cache-Control","no-cache"); 
	response.setDateHeader("Expires", 0); 
%> 


<%
	request.setCharacterEncoding("utf-8");
	String userno = (String)session.getAttribute("userno");
	String row = request.getParameter("row");
	int num = Integer.parseInt(row);
	String progress = request.getParameter("progress");
	int proID = Integer.parseInt(request.getParameter("proID"));
	
	List<Project> plist = new ArrayList<Project>();
	Project p = null;
	plist = Task.getProject(proID);
	if(plist != null && plist.size() > 0) {
		p = plist.get(0);
	} else {
		return;
	}
	
%>		


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<div id="project">
<form id="add-task" action="ReportUploadServlet" method="post" enctype="multipart/form-data" onSubmit="return checkTask();" target="addTask_iframe">
	<input type="hidden" id="level" name="level" value="<%= p.getGrade() %>" />
	<input type="hidden" id="proID" name="proID" value="<%= p.getProID() %>" />
	<input type="hidden" id="fromID" name="fromID" value="<%= userno %>" />
	<input type="hidden" name="row" id="row" value="<%= row %>" />
	<input type="hidden" name="progress" id="progress" value="<%= progress%>" />
	<table cellpadding="0" cellspacing="0">
		<tr><td><label for="name">项目名称：</label></td><td style="text-align:left;"><%= p.getProName() %></td></tr> 
		<tr><td><label for="jober">接收者：</label></td><td style="text-align:left;"><input id="jober" name="toID" style="width:125px;" /></td></tr>  <!--判断一下当前的项目级别，为三级时只返回组长，返回json数据-->
		<tr class="addfiles"><td><label for="file">添加附件：</label></td><td style="text-align:left;"><input type="file" id="file" name="load" style="width:125px;" /></td><td  id="add-file" style="color:#F00;">继续添加附件</td></tr> 
		<tr><td><label for="desc">描述：</label></td><td><textarea id="desc" name="content" style="width:200px; height:120px; overflow:scroll;"></textarea></td></tr>
		 <tr>
      	<td><label for="limit">设置权限:</label></td>
      	<td style="text-align:left;">
      		<select name="limit" id="limit">
      			<option value="all">所有人</option>
      			<option value="limit">权限范围内的人</option>
      		</select>
   		</td> 
	</tr>
		<tr><td colspan="2" align="center"><input type="submit"  id="submit"  value="提交"  style="margin-top:10px;" /></td></tr>
	</table>
</form>
<iframe name="addTask_iframe" style="display:none;">
</iframe>
</div>
<script type="text/javascript">
$("#jober").combobox({
	multiple:true,
	url:'GetTaskObject?level=' + $('#level').attr('value') + '&proID=' + $('#proID').attr('value'),/*返回json数据格式的链接*/
	valueField:"sno",  //getValues
    textField:"sname"  /*！！！！后台同学注意返回json中字段的对应哈，id表示显示顺序，text字段对应的文本显示在下拉框中*/ 

	})

$("#add-file").click(function(){
	var clonefile=$(".addfiles").first().clone();
	if($(".addfiles").length<=4){
  $(".addfiles").last().after(clonefile);
	}
	else{
		alert('亲，一次性最多只能添加5个附件哦');
		}
	})
	
function callback(msg)   
{   
 	//alert(msg);
 	if(msg=='ok'){                              
 		alert('添加成功');
		$('#another').dialog('close');
 		$('#dd').dialog({
		         title:"任务/信息交流",
				 zIndex:9001,
				 width:1000, height:500,
					 top:150,left:100,
				 maximizable:true,
				 cache:false,
				 resizable:true,
				href:'project/teacher/report-detail.jsp?row=' + $('#row').attr('value') + '&progress=' + $('#progress').attr('value'), 
		});
 		$('#another').dialog('close');
 	}
 	else{
	 	alert('添加不成功!');
 	}
 }

	
$('#deadline').datebox({
			formatter:function(date){
				return date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();
				
	}
})

function checkTask() {
			var desc = $('#desc').val();
			var jober = $("#jober").combobox('getValue');
			if (desc && jober) {
				return true;
			} 
			else {
				alert('请补充完整信息');
				return false;
			}
		}
</script>
</body>
</html>
